package com.ruoyi.web.controller.miniapp;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.miniapp.domain.MiniActivitySignup;
import com.ruoyi.miniapp.domain.vo.ActivitySignupVO;
import com.ruoyi.miniapp.service.IMiniActivitySignupService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 活动报名关联Controller
 * 
 * @author duantao
 * @date 2025-09-19
 */
@RestController
@RequestMapping("/miniapp/activitySignUp")
public class MiniActivitySignupController extends BaseController
{
    @Autowired
    private IMiniActivitySignupService miniActivitySignupService;

    /**
     * 查询活动报名关联列表
     */
//    @PreAuthorize("@ss.hasPermi('miniapp:activitySignUp:list')")
    @GetMapping("/list")
    public TableDataInfo list(MiniActivitySignup miniActivitySignup)
    {
        startPage();
        List<MiniActivitySignup> list = miniActivitySignupService.selectMiniActivitySignupList(miniActivitySignup);
        return getDataTable(list);
    }

    /**
     * 导出活动报名关联列表
     */
    @PreAuthorize("@ss.hasPermi('miniapp:activitySignUp:export')")
    @Log(title = "活动报名关联", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MiniActivitySignup miniActivitySignup)
    {
        List<MiniActivitySignup> list = miniActivitySignupService.selectMiniActivitySignupList(miniActivitySignup);
        ExcelUtil<MiniActivitySignup> util = new ExcelUtil<MiniActivitySignup>(MiniActivitySignup.class);
        util.exportExcel(response, list, "活动报名关联数据");
    }

    /**
     * 获取活动报名关联详细信息
     */
//    @PreAuthorize("@ss.hasPermi('miniapp:activitySignUp:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(miniActivitySignupService.selectMiniActivitySignupById(id));
    }

    /**
     * 新增活动报名
     */
//    @PreAuthorize("@ss.hasPermi('miniapp:activitySignUp:add')")
//    @Log(title = "活动报名", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ActivitySignupVO miniActivitySignup)
    {
        if (ObjectUtils.isEmpty(miniActivitySignup)){
            throw new RuntimeException("请检查请求参数！");
        }
        MiniActivitySignup miniActivitySignup1 = miniActivitySignupService.insertMiniActivitySignup(miniActivitySignup);
        return toAjax(1);
    }

    /**
     * 修改活动报名关联
     */
    @PreAuthorize("@ss.hasPermi('miniapp:activitySignUp:edit')")
    @Log(title = "活动报名关联", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MiniActivitySignup miniActivitySignup)
    {
        return toAjax(miniActivitySignupService.updateMiniActivitySignup(miniActivitySignup));
    }

    /**
     * 删除活动报名关联
     */
    @PreAuthorize("@ss.hasPermi('miniapp:activitySignUp:remove')")
    @Log(title = "活动报名关联", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(miniActivitySignupService.deleteMiniActivitySignupByIds(ids));
    }
}
